package com.csun.dsms.task;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.csun.dsms.mapper.*;
import com.csun.dsms.model.education.*;
import com.csun.dsms.model.huang.HgReminderData;
import com.csun.dsms.model.process.TicketProblemInfo;
import com.csun.dsms.utils.pt.HuangGangUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@Component
@EnableScheduling
public class JyTask {

    @Resource
    private JyProblemReportMapper jyProblemReportMapper;
    @Resource
    private JyProblemDetailMapper jyProblemDetailMapper;
    @Resource
    private JyReminderDataMapper jyReminderDataMapper;
    @Resource
    private JyUserMapper jyUserMapper;
    @Resource
    private JyProblemReportBackupMapper jyProblemReportBackupMapper;
    @Resource
    private JyProblemDetailBackupMapper jyProblemDetailBackupMapper;
    @Resource
    private HgUserMapper hgUserMapper;
    @Resource
    private TicketProblemInfoMapper ticketProblemInfoMapper;


//    // 每小时执行一次的定时任务
//    @Scheduled(cron = "0 0 0/1 * * ?")
//    public void queryHgxfData(){
//        DecimalFormat df = new DecimalFormat("0.00%");
//        String url = "https://sqpt.ihuanggang.cn/wxmdjfpchj-backend/dataProcess/queryPetitionPage";
//        String reqString = "{\"pageNum\":1,\"data\":{\"isExport\":false,\"mainId\":\"\",\"petitioner\":\"\",\"handlingStatus\":\"办结\",\"problemLocation\":\"\",\"destinationUnit\":\"\",\"appealLevel\":\"\",\"contentCategory\":\"\"},\"pageSize\":12}";
//        try {
//            String respString = HttpUtil.post(url, reqString);
//            log.info("查询黄冈办结数据：{}",respString);
//            JSONObject resJson = JSONObject.parseObject(respString);
//            Integer code = resJson.getInteger("code");
//            if (code == 200){
//                JSONObject data = resJson.getJSONObject("data");
//                Integer total = data.getInteger("total");
//                JyProblemReport jyProblemReport = new JyProblemReport();
//                jyProblemReport.setId(1L);
//                jyProblemReport.setProminentIssue("信访积案化解");
//                jyProblemReport.setLeadingUnit("市信访局");
//                JyProblemReport jyProblemReportOld = jyProblemReportMapper.selectOne(jyProblemReport);
//                if (jyProblemReportOld!=null){
//                    jyProblemReportOld.setTask2Json(String.valueOf(total));
//                    jyProblemReportOld.setTask3Json(df.format((double)total/ Convert.toInt(jyProblemReportOld.getTask1Json())));
//                    jyProblemReportMapper.updateByPrimaryKeySelective(jyProblemReportOld);
//                }
//            }
//
//        } catch (Exception e) {
//            log.error("定时查询黄冈办结异常：",e);
//        }
//    }

    // 调用这个接口更新县市区的数据
    // 同步更新total数据
//    @Scheduled(cron = "0 0 0/1 * * ?")
//    public void queryHgxfData2(){
//        DecimalFormat df = new DecimalFormat("0.00%");
//        String url = "https://sqpt.ihuanggang.cn/wxmdjfpchj-backend/dataProcess/queryStatisticsArea";
//        String reqString = "{\"xcType\":1}";
//        try {
//            String respString = HttpUtil.post(url, reqString);
//            log.info("查询黄冈办结数据：{}",respString);
//            JSONObject resJson = JSONObject.parseObject(respString);
//            Integer code = resJson.getInteger("code");
//            if (code == 200){
//                JSONArray array = resJson.getJSONArray("data");
//                List<JyProblemDetail> jyProblemDetailList = new ArrayList<>();
//                for (int i = 0; i < array.size(); i++) {
//                    JyProblemDetail jyProblemDetail = new JyProblemDetail();
//                    JSONObject itemObj = (JSONObject) array.get(i);
//                    String districtName = itemObj.getString("districtName");
//                    Integer total = itemObj.getInteger("total");
//                    Integer finishedCount = itemObj.getInteger("finishedCount");
//                    if (districtName.equals("黄冈市")){
//                        districtName = "市本级";
//                    }
//                    jyProblemDetail.setRegion(districtName);
//                    jyProblemDetail.setField1(""+total);
//                    jyProblemDetail.setField2(""+finishedCount);
//                    jyProblemDetailList.add(jyProblemDetail);
//                }
//                // 合并"市本级"和"黄冈市高新区"的数据
//                int mergedTotal = 0;
//                int allTotal = 0;
//                int allFinish = 0;
//                int mergedFinished = 0;
//                List<JyProblemDetail> mergedList = new ArrayList<>();
//
//                for (JyProblemDetail detail : jyProblemDetailList) {
//                    if ("市本级".equals(detail.getRegion()) ||
//                            "黄冈高新技术产业开发区".equals(detail.getRegion())) {
//                        // 累加需要合并的数据
//                        mergedTotal += Integer.parseInt(detail.getField1());
//                        mergedFinished += Integer.parseInt(detail.getField2());
//                    } else {
//                        // 非合并区域直接保留
//                        mergedList.add(detail);
//                    }
//                    allTotal +=  Integer.parseInt(detail.getField1());
//                    allFinish +=  Integer.parseInt(detail.getField2());
//                }
//
//                // 创建合并后的数据项
//                if (mergedTotal > 0 || mergedFinished > 0) {
//                    JyProblemDetail mergedDetail = new JyProblemDetail();
//                    mergedDetail.setRegion("市本级");
//                    mergedDetail.setField1(String.valueOf(mergedTotal));
//                    mergedDetail.setField2(String.valueOf(mergedFinished));
//
//                    // 计算百分比（保留两位小数）
//                    double percentage = (mergedFinished * 100.0) / mergedTotal;
//                    mergedDetail.setField3(String.format("%.2f%%", percentage));
//                    mergedList.add(mergedDetail);
//                }
//                jyProblemDetailList = mergedList; // 更新结果列表
//                jyProblemDetailList.forEach(item->{
//                    JyProblemDetail queryItem = new JyProblemDetail();
//                    queryItem.setRegion(item.getRegion());
//                    queryItem.setProject("信访积案化解");
//                    queryItem.setContent("信访问题");
//                    JyProblemDetail queryDetail = jyProblemDetailMapper.selectOne(queryItem);
//                    if (queryDetail!=null){
//                        queryDetail.setField1(item.getField1());
//                        queryDetail.setField2(item.getField2());
//                        double percentage = (Integer.parseInt(item.getField2()) * 100.0) / Integer.parseInt(item.getField1());
//                        queryDetail.setField3(String.format("%.2f%%", percentage));
//                        jyProblemDetailMapper.updateByPrimaryKeySelective(queryDetail);
//                    }
//                });
//                JyProblemReport jyProblemReport = new JyProblemReport();
//                jyProblemReport.setId(1L);
//                jyProblemReport.setProminentIssue("信访积案化解");
//                jyProblemReport.setLeadingUnit("市信访局");
//                JyProblemReport jyProblemReportOld = jyProblemReportMapper.selectOne(jyProblemReport);
//                if (jyProblemReportOld!=null){
//                    jyProblemReportOld.setTask1Json(String.valueOf(allTotal));
//                    jyProblemReportOld.setTask2Json(String.valueOf(allFinish));
//                    jyProblemReportOld.setTask3Json(df.format((double)allFinish/ Convert.toInt(jyProblemReportOld.getTask1Json())));
//                    jyProblemReportMapper.updateByPrimaryKeySelective(jyProblemReportOld);
//                }
//
////                JSONObject data = resJson.getJSONObject("data");
////                Integer total = data.getInteger("total");
////                JyProblemReport jyProblemReport = new JyProblemReport();
////                jyProblemReport.setId(1L);
////                jyProblemReport.setProminentIssue("信访积案化解");
////                jyProblemReport.setLeadingUnit("市信访局");
////                JyProblemReport jyProblemReportOld = jyProblemReportMapper.selectOne(jyProblemReport);
////                if (jyProblemReportOld!=null){
////                    jyProblemReportOld.setTask2Json(String.valueOf(total));
////                    jyProblemReportOld.setTask3Json(df.format((double)total/ Convert.toInt(jyProblemReportOld.getTask1Json())));
////                    jyProblemReportMapper.updateByPrimaryKeySelective(jyProblemReportOld);
////                }
//            }
//
//        } catch (Exception e) {
//            log.error("定时查询黄冈办结异常：",e);
//        }
//    }

    //
    //https://sqpt.ihuanggang.cn/wxmdjfpchj-backend/dataProcess/queryStatisticsArea


    // 每小时执行一次的定时任务
    @Scheduled(cron = "0 0 0/1 * * ?")
//    @Scheduled(cron = "0 * * * * ?")
    public void pushWarningData() {
        try {
            List<JyProblemReport> jyProblemReports = jyProblemReportMapper.selectAll();
            for (JyProblemReport jyProblemReport : jyProblemReports) {
                JyReminderData queryJyReminderData = new JyReminderData();

                queryJyReminderData.setIsConfirmed(0);
                queryJyReminderData.setReminderDepart(jyProblemReport.getLeadingUnit());
                List<JyReminderData> queryJyReminderDataList = jyReminderDataMapper.select(queryJyReminderData);
                if (CollectionUtil.isNotEmpty(queryJyReminderDataList)) {
                    continue;
                }

                String prominentIssue = jyProblemReport.getProminentIssue();
                String Task1Name = jyProblemReport.getTask1Name();
                String Task2Name = jyProblemReport.getTask2Name();
                String Task3Name = jyProblemReport.getTask3Name();
                String Task4Name = jyProblemReport.getTask4Name();
                String Task5Name = jyProblemReport.getTask5Name();
                String Task6Name = jyProblemReport.getTask6Name();
                String Task7Name = jyProblemReport.getTask7Name();
                String task1Json = jyProblemReport.getTask1Json();
                String task2Json = jyProblemReport.getTask2Json();
                String task3Json = jyProblemReport.getTask3Json();
                String task4Json = jyProblemReport.getTask4Json();
                String task5Json = jyProblemReport.getTask5Json();
                String task6Json = jyProblemReport.getTask6Json();
                String task7Json = jyProblemReport.getTask7Json();
                String bottomThreeEvaluation = jyProblemReport.getBottomThreeEvaluation();
                if (StrUtil.isNotBlank(bottomThreeEvaluation)) {
                    String[] bottomThreeEvaluationArray = bottomThreeEvaluation.split("\n");
                    for (String area : bottomThreeEvaluationArray) {
                        area = area.trim();
                        if (StrUtil.isNotBlank(area)) {
                            addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), "排名后三位",area + ":" + prominentIssue + "，处于后三位，请注意！", area);
                        }
                    }
                }
                switch (prominentIssue) {
                    case "信访积案化解":
                        if (StrUtil.isNotBlank(task3Json)) {
                            Double task3JsonD = Convert.toDouble(task3Json);
                            if (task3JsonD < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(),Task1Name,Task1Name + "指标" + Task3Name + task3Json + "，请注意！", null);
                            }
                        }
                        break;
                    case "后进村整顿":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "行政村布局调整后半篇文章":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "矛盾纠纷实质性化解":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "道路交通安全综合治理":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 20) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 20) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "执行难破产难":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "不担当不作为":
                        if (StrUtil.isNotBlank(task2Json)) {
                            Double task2JsonD = Convert.toDouble(task2Json);
                            if (task2JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + task2Json + "，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task4Json)) {
                            Double task4JsonD = Convert.toDouble(task4Json);
                            if (task4JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task4Name,Task4Name + "指标" + task4Json + "，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task6Json)) {
                            Double task6JsonD = Convert.toDouble(task6Json);
                            if (task6JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task6Name,Task6Name + "指标" + task6Json + "，请注意！", null);
                            }
                        }
                        break;
                    case "违规吃喝":
                        if (StrUtil.isNotBlank(task2Json)) {
                            Double task2JsonD = Convert.toDouble(task2Json);
                            if (task2JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + task2Json + "，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task4Json)) {
                            Double task4JsonD = Convert.toDouble(task4Json);
                            if (task4JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task4Name,Task4Name + "指标" + task4Json + "，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task6Json)) {
                            Double task6JsonD = Convert.toDouble(task6Json);
                            if (task6JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task6Name,Task6Name + "指标" + task6Json + "，请注意！", null);
                            }
                        }
                        break;
                    case "违规收送礼品礼金":
                        if (StrUtil.isNotBlank(task2Json)) {
                            Double task2JsonD = Convert.toDouble(task2Json);
                            if (task2JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + task2Json + "，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task4Json)) {
                            Double task4JsonD = Convert.toDouble(task4Json);
                            if (task4JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task4Name,Task4Name + "指标" + task4Json + "，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task6Json)) {
                            Double task6JsonD = Convert.toDouble(task6Json);
                            if (task6JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task6Name,Task6Name + "指标" + task6Json + "，请注意！", null);
                            }
                        }
                        break;
                    case "违规打牌和赌博":
                        if (StrUtil.isNotBlank(task2Json)) {
                            Double task2JsonD = Convert.toDouble(task2Json);
                            if (task2JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + task2Json + "，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task4Json)) {
                            Double task4JsonD = Convert.toDouble(task4Json);
                            if (task4JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task4Name,Task4Name + "指标" + task4Json + "，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task6Json)) {
                            Double task6JsonD = Convert.toDouble(task6Json);
                            if (task6JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task6Name,Task6Name + "指标" + task6Json + "，请注意！", null);
                            }
                        }
                        break;
                    case "酒驾醉驾":
                        if (StrUtil.isNotBlank(task2Json)) {
                            Double task2JsonD = Convert.toDouble(task2Json);
                            if (task2JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + task2Json + "，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task4Json)) {
                            Double task4JsonD = Convert.toDouble(task4Json);
                            if (task4JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task4Name,Task4Name + "指标" + task4Json + "，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task6Json)) {
                            Double task6JsonD = Convert.toDouble(task6Json);
                            if (task6JsonD > 50) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task6Name,Task6Name + "指标" + task6Json + "，请注意！", null);
                            }
                        }
                        break;
                    case "中小学校园餐":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "公共交通服务质量不优":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "物业服务履约不到位、侵占业主公共收益":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "大气污染":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task4Json)) {
                            JSONArray task4JsonArray = JSONArray.parseArray(task4Json);
                            JSONObject task4JsonObject = task4JsonArray.getJSONObject(2);
                            String name = task4JsonObject.getString("name");
                            Double value = Convert.toDouble(task4JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task4Name,Task4Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "12345投诉办理质效不高":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "新就业群体急难愁盼":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task4Json)) {
                            JSONArray task4JsonArray = JSONArray.parseArray(task4Json);
                            JSONObject task4JsonObject = task4JsonArray.getJSONObject(2);
                            String name = task4JsonObject.getString("name");
                            Double value = Convert.toDouble(task4JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task4Name,Task4Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "民生案件破案":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task4Json)) {
                            JSONArray task4JsonArray = JSONArray.parseArray(task4Json);
                            JSONObject task4JsonObject = task4JsonArray.getJSONObject(2);
                            String name = task4JsonObject.getString("name");
                            Double value = Convert.toDouble(task4JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task4Name,Task4Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task5Json)) {
                            JSONArray task5JsonArray = JSONArray.parseArray(task5Json);
                            JSONObject task5JsonObject = task5JsonArray.getJSONObject(2);
                            String name = task5JsonObject.getString("name");
                            Double value = Convert.toDouble(task5JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task5Name,Task5Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task6Json)) {
                            JSONArray task6JsonArray = JSONArray.parseArray(task6Json);
                            JSONObject task6JsonObject = task6JsonArray.getJSONObject(2);
                            String name = task6JsonObject.getString("name");
                            Double value = Convert.toDouble(task6JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task6Name,Task6Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task7Json)) {
                            JSONArray task7JsonArray = JSONArray.parseArray(task7Json);
                            JSONObject task7JsonObject = task7JsonArray.getJSONObject(2);
                            String name = task7JsonObject.getString("name");
                            Double value = Convert.toDouble(task7JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task7Name,Task7Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "命案防范":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(4);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 20) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "未成年人保护和预防犯罪":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "精神障碍患者服务管理":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "电信网络诈骗打击":
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "禁毒工作":
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "高额彩礼":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task4Json)) {
                            JSONArray task4JsonArray = JSONArray.parseArray(task4Json);
                            JSONObject task4JsonObject = task4JsonArray.getJSONObject(2);
                            String name = task4JsonObject.getString("name");
                            Double value = Convert.toDouble(task4JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task4Name,Task4Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "外籍新娘管理服务":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task4Json)) {
                            JSONArray task4JsonArray = JSONArray.parseArray(task4Json);
                            JSONObject task4JsonObject = task4JsonArray.getJSONObject(2);
                            String name = task4JsonObject.getString("name");
                            Double value = Convert.toDouble(task4JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task4Name,Task4Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "失能失智老人日间照护":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task4Json)) {
                            JSONArray task4JsonArray = JSONArray.parseArray(task4Json);
                            JSONObject task4JsonObject = task4JsonArray.getJSONObject(2);
                            String name = task4JsonObject.getString("name");
                            Double value = Convert.toDouble(task4JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task4Name,Task4Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "留守妇女关心关爱":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task4Json)) {
                            JSONArray task4JsonArray = JSONArray.parseArray(task4Json);
                            JSONObject task4JsonObject = task4JsonArray.getJSONObject(2);
                            String name = task4JsonObject.getString("name");
                            Double value = Convert.toDouble(task4JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task4Name,Task4Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "农村留守儿童假期托管":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "农村慢性病管理心电一张网":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "中小学生午休趴睡变躺睡":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                    case "市区老年人娱乐活动和场所建设":
                        if (StrUtil.isNotBlank(task1Json)) {
                            JSONArray task1JsonArray = JSONArray.parseArray(task1Json);
                            JSONObject task1JsonObject = task1JsonArray.getJSONObject(2);
                            String name = task1JsonObject.getString("name");
                            Double value = Convert.toDouble(task1JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task1Name,Task1Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task2Json)) {
                            JSONArray task2JsonArray = JSONArray.parseArray(task2Json);
                            JSONObject task2JsonObject = task2JsonArray.getJSONObject(2);
                            String name = task2JsonObject.getString("name");
                            Double value = Convert.toDouble(task2JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task2Name,Task2Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        if (StrUtil.isNotBlank(task3Json)) {
                            JSONArray task3JsonArray = JSONArray.parseArray(task3Json);
                            JSONObject task3JsonObject = task3JsonArray.getJSONObject(2);
                            String name = task3JsonObject.getString("name");
                            Double value = Convert.toDouble(task3JsonObject.getString("value"));
                            if (value != null && value < 80) {
                                addReminderData(jyProblemReport.getLeadingLeader(),jyProblemReport.getLeadingUnit(), Task3Name,Task3Name + "指标" + name + value + "%，请注意！", null);
                            }
                        }
                        break;
                }

            }
        } catch (Exception e) {
            log.error("定时生成预警数据异常：", e);
        }
    }

    // 每天23:30执行
    @Scheduled(cron = "0 30 23 * * ?")
//    @Scheduled(cron = "0 * * * * ?")
    public void dataBackup() {
        DateTime date = DateUtil.date();
        String dateStr = DateUtil.format(date, DatePattern.PURE_DATE_PATTERN);
        JyProblemReportBackup jyProblemReportBackup = new JyProblemReportBackup();
        JyProblemDetailBackup jyProblemDetailBackup = new JyProblemDetailBackup();

        jyProblemReportBackup.setBackup(dateStr);
        jyProblemDetailBackup.setBackup(dateStr);
        List<JyProblemDetailBackup> jyProblemDetailBackupList = jyProblemDetailBackupMapper.select(jyProblemDetailBackup);
        List<JyProblemReportBackup> jyProblemReportBackupList = jyProblemReportBackupMapper.select(jyProblemReportBackup);


        List<JyProblemReport> jyProblemReports = jyProblemReportMapper.selectAll();
        List<JyProblemDetail> jyProblemDetails = jyProblemDetailMapper.selectAll();

        if (CollectionUtil.isEmpty(jyProblemDetailBackupList)){
            for (JyProblemDetail jyProblemDetail : jyProblemDetails) {
                JyProblemDetailBackup jyProblemDetailBackup1 = new JyProblemDetailBackup();
                BeanUtil.copyProperties(jyProblemDetail, jyProblemDetailBackup1);
                jyProblemDetailBackup1.setId(IdUtil.simpleUUID());
                jyProblemDetailBackup1.setBackup(dateStr);
                jyProblemDetailBackup1.setBackupTime(date);
                jyProblemDetailBackupMapper.insertSelective(jyProblemDetailBackup1);
            }
        }

        if(CollectionUtil.isEmpty(jyProblemReportBackupList)){
            for (JyProblemReport jyProblemReport : jyProblemReports) {
                JyProblemReportBackup jyProblemReportBackup1 = new JyProblemReportBackup();
                BeanUtil.copyProperties(jyProblemReport, jyProblemReportBackup1);
                jyProblemReportBackup1.setId(IdUtil.simpleUUID());
                jyProblemReportBackup1.setBackup(dateStr);
                jyProblemReportBackup1.setBackupTime(date);
                jyProblemReportBackupMapper.insertSelective(jyProblemReportBackup1);
            }
        }
    }

    public void addReminderData(String leadingLeader,String leadingUnit,String reminderTitle,String reminderContent,String area) {
        if (StrUtil.isBlank(leadingUnit)) {
            return;
        }
        DateTime date = DateUtil.date();
        DateTime completeDeadline = DateUtil.offset(date, DateField.DAY_OF_MONTH, 3);
//        JyUser jyUser = new JyUser();
//        jyUser.setDepartment(leadingUnit);
//        if (StrUtil.isNotBlank(area)){
//            jyUser.setArea(area);
//        }
//        List<JyUser> jyUserList = jyUserMapper.select(jyUser);
//        if(CollectionUtil.isNotEmpty(jyUserList)){
//            for (JyUser user : jyUserList) {
//                JyReminderData jyReminderData = new JyReminderData();
//                jyReminderData.setReminderPerson(user.getRealName());
//                jyReminderData.setReminderPhoneNumber(user.getPhone());
//                jyReminderData.setCreatedTime(date);
//                jyReminderData.setReminderDepart(leadingUnit);
//                jyReminderData.setReminderTime(date);
//                jyReminderData.setReminderType(1);
//                jyReminderData.setIsConfirmed(0);
//                jyReminderData.setReminderContent(reminderContent);
//                jyReminderData.setReminderTitle(reminderTitle);
//                jyReminderDataMapper.insertSelective(jyReminderData);
//            }
//        }
        JyReminderData jyReminderData = new JyReminderData();
        jyReminderData.setReminderPerson(leadingLeader);
        jyReminderData.setCreatedTime(date);
        jyReminderData.setReminderDepart(leadingUnit);
        jyReminderData.setReminderTime(date);
        jyReminderData.setReminderType(1);
        jyReminderData.setIsConfirmed(0);
        jyReminderData.setReminderContent(reminderContent);
        jyReminderData.setReminderTitle(reminderTitle);
        jyReminderData.setRiskLevel("1");
        jyReminderData.setCompleteDeadline(completeDeadline);
        jyReminderDataMapper.insertSelective(jyReminderData);

        JyUser queryJyUser = new JyUser();
        queryJyUser.setDepartment(leadingUnit);
        List<JyUser> jyUserList = jyUserMapper.select(queryJyUser);
        if (CollectionUtil.isNotEmpty(jyUserList)) {
            for (JyUser jyUser : jyUserList) {
            HgReminderData hgReminderData = new HgReminderData();
            hgReminderData.setIHgUser(jyUser.getHuangGangId());
            hgReminderData.setReminderPerson(jyUser.getRealName());
            hgReminderData.setCreatedTime(date);
            hgReminderData.setReminderDepart(jyUser.getDepartment());
            hgReminderData.setReminderPhoneNumber(jyUser.getPhone());
            hgReminderData.setReminderTime(date);
            hgReminderData.setReminderType(4);
            hgReminderData.setReminderContent(reminderContent);
            hgReminderData.setReminderTitle(reminderTitle);
            HuangGangUtil.sendJyMsg(hgReminderData);
            }
        }

    }

    /**
     * 预警升级
     * 每小时执行一次的定时任务
     */
    @Scheduled(cron = "0 0 0/1 * * ?")
    public void warningUpgrade() {
        DateTime date = DateUtil.date();
        JyReminderData queryJyReminderData = new JyReminderData();
        queryJyReminderData.setIsConfirmed(0);
        queryJyReminderData.setRiskLevel("0");
        List<JyReminderData> queryJyReminderDataList = jyReminderDataMapper.select(queryJyReminderData);
        queryJyReminderDataList = queryJyReminderDataList.stream().filter(data -> data.getCompleteDeadline() != null
                && data.getCompleteDeadline().before(date)).collect(Collectors.toList());
        queryJyReminderDataList.forEach(data -> {
            data.setRiskLevel("2");
            jyReminderDataMapper.updateByPrimaryKeySelective(data);
        });
    }

    /**
     * 预警升级
     * 凌晨一点一次
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void warningTicket() {
        DateTime date = DateUtil.date();
        DateTime date3 = DateUtil.offsetDay(DateUtil.date(),-3);
        TicketProblemInfo queryTicketProblemInfo = new TicketProblemInfo();
        queryTicketProblemInfo.setStatus("0");
        List<TicketProblemInfo> queryTicketProblemInfoList = ticketProblemInfoMapper.select(queryTicketProblemInfo);
        List<TicketProblemInfo> queryTicketProblemInfoList1 = queryTicketProblemInfoList.stream().filter(data -> data.getCompleteDeadline() != null
                && data.getCompleteDeadline().before(date3)).collect(Collectors.toList());
        queryTicketProblemInfoList1.forEach(ticketProblemInfo -> {
            JyReminderData jyReminderData = new JyReminderData();
            jyReminderData.setCreatedTime(date);
            jyReminderData.setReminderDepart(ticketProblemInfo.getLeadUnit());
            jyReminderData.setReminderTime(date);
            jyReminderData.setReminderType(1);
            jyReminderData.setIsConfirmed(0);
            jyReminderData.setReminderContent("工单[" + ticketProblemInfo.getTicketNo() + "],牵头单位["+ticketProblemInfo.getLeadUnit()+"]距离办结期限还有3天，请注意！");
            jyReminderData.setReminderTitle("距离办结期限还有3天，请注意！");
            jyReminderData.setRiskLevel("1");
            jyReminderDataMapper.insertSelective(jyReminderData);

            ticketProblemInfo.setRiskLevel("2");
            ticketProblemInfoMapper.updateByPrimaryKeySelective(ticketProblemInfo);
        });

        List<TicketProblemInfo> queryTicketProblemInfoList2 = queryTicketProblemInfoList.stream().filter(data -> data.getCompleteDeadline() != null
                && data.getCompleteDeadline().before(date)).collect(Collectors.toList());
        queryTicketProblemInfoList2.forEach(ticketProblemInfo -> {
            JyReminderData jyReminderData = new JyReminderData();
            jyReminderData.setCreatedTime(date);
            jyReminderData.setReminderDepart(ticketProblemInfo.getLeadUnit());
            jyReminderData.setReminderTime(date);
            jyReminderData.setReminderType(1);
            jyReminderData.setIsConfirmed(0);
            jyReminderData.setReminderContent("工单[" + ticketProblemInfo.getTicketNo() + "],牵头单位["+ticketProblemInfo.getLeadUnit()+"]已超期，请及时处理！");
            jyReminderData.setReminderTitle("已超期，请及时处理！");
            jyReminderData.setRiskLevel("2");
            jyReminderDataMapper.insertSelective(jyReminderData);

            ticketProblemInfo.setRiskLevel("3");
            ticketProblemInfoMapper.updateByPrimaryKeySelective(ticketProblemInfo);
        });
    }

}
